package com.ffyc.backserver.service;

import com.ffyc.backserver.dao.LoginDao;
import com.ffyc.backserver.model.Admin;
import com.ffyc.backserver.model.Menu;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional//Sping事务
public class LoginService {
@Autowired
LoginDao loginDao;

    public Admin login(Admin admin) {
        /*密码加密*/
        admin.setPassword(DigestUtils.md5Hex(admin.getPassword()));
       return loginDao.login(admin);

    }

    public List<Menu>findMenu(Integer id,Integer type) {
        Admin admin=new Admin();
        admin.setId(id);
        admin.setType(type);
        return loginDao.findMenu(admin);

    }

}
